package com.gxa.controller.department;

import com.gxa.common.R.ResponseData;
import com.gxa.pojo.Dept;
import com.gxa.service.department.DeptService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/*
1.2部门信息列表
 */
@Controller
@Api(value = "部门信息test",tags = "部门信息接口API")
@RequestMapping("/dept")
    public class DeptInformationController {

    @Autowired
    private DeptService deptService;//调用service层接口
    /*
    1.2.1 查询部门信息
     */
    @RequestMapping(value = "/findInformationList",method = RequestMethod.GET)
    @ApiOperation(value = "部门分级查询接口", notes = "提供当前页码数与每页显示条数", httpMethod = "get", response = ResponseData.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage", value = "当前页数", required = true, dataType = "String"),
            @ApiImplicitParam(name = "pageSize", value = "每页显示条数", required = true, dataType = "String"),
    })//显示页面
    @ApiResponses({
            @ApiResponse(code = 200, message = "请求成功"),
            @ApiResponse(code = 404, message = "页面未找到"),
            @ApiResponse(code = 500, message = "后台处理错误")
    })
    @ResponseBody//返回对象
    public ResponseData FindInformationList(@RequestParam(name = "currentPage") String currentPage,
                                            @RequestParam(name = "pageSize") String pageSize){
        return deptService.findInformationList(currentPage, pageSize);
    }

    /*
    1.2.2 修改部门信息
     */
   @RequestMapping(value = "/updateDepartment",method = RequestMethod.POST)
   @ApiResponses({
           @ApiResponse(code=200,message="请求成功"),
           @ApiResponse(code=404,message="找不到页面"),
           @ApiResponse(code=500,message="后台服务错误")
   })
   @ResponseBody
    public ResponseData updateDepartment(@RequestBody@ApiParam(name = "修改部门信息",required = false) Dept dept){
       return deptService.updateDepartment(dept);
   }
   //1.2.3 删除部门
    @RequestMapping(value = "/deleteDepartment",method = RequestMethod.POST)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public ResponseData DeleteDepartment(@RequestParam@ApiParam(name = "删除部门id",required = true) String id){
      return deptService.deleteDepartment(id);
    }
}
